package Com.javaserver.servlet;

import Com.javaserver.bean.invite;
import Com.javaserver.bean.rewland;
import Com.javaserver.dao.inviteserver;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@WebServlet("/addinvite")
public class inviteaddserverlet extends HttpServlet {
    inviteserver invit=new inviteserver();
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        String name=req.getParameter("name");//奖惩主题
        String sex=req.getParameter("sex");//奖惩类型
        if (sex.equals("1")){
            sex="男";
        }else{
            sex="女";
        }
        String age=req.getParameter("age");//奖惩金额
        String brith=req.getParameter("brith");//奖惩时间
        String position=req.getParameter("position");//奖惩原因
        String major=req.getParameter("major");
        String experience=req.getParameter("experience");
        String education=req.getParameter("education");
        if (education.equals("1")) {
            education="本科生";
        }else{
            education="研究生";
        }
        String phone=req.getParameter("phone");
        String shool=req.getParameter("shool");
        String home=req.getParameter("home");
        String time=req.getParameter("time");
        String profile=req.getParameter("profile");
       invite in=new invite();
        in.setC_name(name);
        in.setC_sex(sex);
        in.setC_age(age);
        in.setC_birth(brith);
        in.setC_position(position);
        in.setC_major(major);
        in.setC_experience(experience);
        in.setC_education(education);
        in.setC_phone(phone);
        in.setC_shool(shool);
        in.setC_home(home);
        in.setC_time(time);
        in.setC_profile(profile);
        if (invit.addinvite(in)==null){
            req.getSession().setAttribute("msg","添加失败");
            resp.sendRedirect(req.getContextPath()+"/AddRecruitment.jsp");
        }else {
            //这个地方放重新刷新的页面List
            List<invite> list=invit.inlist(1);
            req.getSession().setAttribute("invitlist",list);
            req.getSession().setAttribute("msg","添加成功");

            resp.sendRedirect(req.getContextPath()+"/inlist");
        }
    }

}
